package com.bms.cfcmms.model.system;

import com.bms.cfcmms.util.annotation.TableDefine;
import com.bms.cfcmms.model.BaseModel;
import com.bms.cfcmms.util.annotation.FieldDefine;
import lombok.Data;

import java.sql.Timestamp;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;


/**
 * Created by carl on 2016/4/8.
 */
@Data
@TableDefine(group = "系统设置", primaryKey = "userId", id = 9908, title = "用户")
public class User extends BaseModel {

    private static final long serialVersionUID = -4018384526282246891L;

    @FieldDefine()
    @Column
    private Integer userId;

    @FieldDefine()
    @ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
    @Column(name = "departmentId", nullable = false)
    @Size(max = 10)
    private String departmentId;

    @FieldDefine()
    @Column(length = 20, nullable = false)
    @Size(max = 20)
    private String userName;

    @FieldDefine()
    @Column(length = 20, nullable = false)
    @NotNull
    @Size(max = 20, message = "{User.loginName.size}")
    private String loginName;

    @FieldDefine()
    @Column(nullable = false)
    private Boolean allowLogin;

    @Column(length = 50, nullable = false)
    @NotNull
    @Size(max = 50)
    private String password;

    @FieldDefine()
    @Column(length = 50)
    @Size(max = 50)
    private String office;

    @FieldDefine()
    @Column(length = 20)
    @Size(max = 20)
    private String telnumber;

    @FieldDefine()
    @Column(length = 20)
    @Size(max = 20)
    private String phonenumber;

    @FieldDefine()
    @Column(length = 50)
    @Size(max = 50)
    private String eMail;

    @FieldDefine()
    @Column(length = 20)
    @Size(max = 20)
    private String qq;

    @FieldDefine()
    private Boolean isSendMessage;

    @FieldDefine()
    private Timestamp lastLoginDate;

    @FieldDefine()
    private Integer loginTimes;

    @FieldDefine()
    @Size(max = 255)
    private String remark;
}
